import openpyxl as vb

path = '../文件/列或行求和.xlsx'
wb = vb.load_workbook(path)
wt = wb["Sheet1"]


# maxRow = wt.max_row
# maxColumn = wt.max_column
# for row in wt.iter_rows(1, maxRow, 1, maxColumn):
#     print([cellRow.value for cellRow in row])


# for row in wt.rows:
#     print([cellRow.value for cellRow in row][1:])


# """
# 按行求和
# """
# for row in list(wt.rows)[1:]:
#     data = [cellRow.value for cellRow in row]
#     print(data[0], sum(data[1:]))


"""
按列求和
"""
for column in list(wt.columns)[1:]:
    data = [cellCol.value for cellCol in column]
    print(data[0], sum(data[1:]))
